/**
 * Created with Vim7.3 ubuntu12.04
 * @fileOverview : 
 * @author : Lyle <lylechen2014@gmial.com>
 * @since : 2014-10-13 14:51:37
 * @filename : static/logic/nmm/src/views/editAboutMyFirstDateIdea.tpl
 * @version : 
 * @description : 
 */

define(function(require, exports, module){

    var editAboutMyFirstDateIdeaView,
        mId = 'editAboutMyFirstDateIdea',reRender = false,menuName = 'editAboutMyFirstDateIdea',
        imglazyload = require('{component}imglazyload/zepto.imglazyload'),
        panel = require('{component}panel/zepto.panel'),
        tpl = require('{view}editAboutMyFirstDateIdea.tpl'),
        tplN = require('{view}userNav.tpl');

    editAboutMyFirstDateIdeaView = Backbone.View.extend({

        template: _.template(tpl),
        templateN: _.template(tplN),

        bindEvt : function() {
            var tthis = this,dom=$('#'+mId);

            dom.find('.back').on('tap',function(e){
                window.location.href = '#myProfile/whole/custom1'; 
            });

            dom.find('.save').on('tap',function(e){
                var value = dom.find('.textarea_large').find('textarea').val();
                if (value.length < 50) {
                    alert('30 characters minimum');
                } else if (value.length > 2000) {
                    alert('2000 characters maxmum');
                } else {
                    var usr_id = userObj.account.usr_id;
                    var callback = function(){
                        userObj.about.firstidea = value;
                        share.cacheUserInfo(usr_id,userObj);
                        window.location.href = '#myProfile/whole/custom1'; 
                    }
                    var obj = {perfect_date : value};
                    share.updateProfile(usr_id,callback,obj);
                }   
            });
        },      

        render: function (obj) {
            if (!share.checkPermission(true)){return;}; 
            share.reRender(reRender,mId); 
            userObj = share.getObjStorage(share.userInfo().usr_id);
            if ($('#'+mId).length < 1) { 
                $('body').append(this.template(lang));
                this.bindEvt(); 
            } else {
                $('#'+mId).css('display','block');
            }
            share.panel(panel,this.templateN,mId,menuName);
            $('#'+mId).find('.textarea_large').find('textarea').val(share.handleVal(userObj.about.firstidea)); 
        }
	});
	module.exports = editAboutMyFirstDateIdeaView;
})

